import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

public class Server extends Thread {
	private int port;

	public static void main(String[] args) {
		for (int i = 0; i < Client.AMOUNT_OF_SERVERS_THAT_IS_RUNNING_REMOTELY_AND_ACCESSED_WITH_RMI; i++) {
			(new Server(15000 + i)).start();
		}
	}

	public Server(int p) {
		port = p;
	}

	public void run() {
		try {
			LocateRegistry.createRegistry(port);
			Spider sp = new Spider();
			Naming.rebind("//localhost:" + port + "/spider", sp);
			System.out.println("Test server ready at port " + port);
		} catch (RemoteException rex) {
			System.out.println("Exception in Test.main: " + rex);
		} catch (MalformedURLException ex) {
			System.out.println("MalformedURLException " + ex);
		}
	}
}
